package com.example.blades.xmlex0411;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Created by Blades on 2018/4/13.
 */

public class otherActivity extends Activity {
    Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.other);
    /*取得Intent中的Bundle对象*/
    Bundle bundle=this.getIntent().getExtras();
        /*取得Bundle对象中的数据*/
    String ans=bundle.getString("ans");
        /*判断所选答案*/
    String setText;
        if(ans.equals("on"))
        {
            setText="正确";
        }
        else
        {
            setText="错误";
        }

        TextView tv1=(TextView)findViewById(R.id.text1);
        tv1.setText("选择的答案是："+ans+","+setText);

        /*以findViewById()取得Button对象，并添加onClickListener*/
        Button b1=(Button)findViewById(R.id.button_back);
        b1.setOnClickListener(new Button.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                /*返回result，回上一个Activity*/
                otherActivity.this.setResult(RESULT_OK,intent);

                /*结束这个activity*/
                otherActivity.this.finish();
            }
        });
    }
}
